FROM golang:alpine3.13 as builder

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories

RUN apk update && apk add --no-cache --virtual .tmp \
  tzdata; cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime; \
  echo "Asia/Shanghai" > /etc/timezone; \
  apk del .tmp

WORKDIR /go/src/lotusmonitor

COPY . .

ENV GOPROXY=https://goproxy.io

RUN mkdir -p build

RUN go build -o build/lotusmonitor cmd/lotusmonitor/main.go

FROM alpine:3.13

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories

RUN apk update && apk add --no-cache --virtual .tmp \
  tzdata; cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime; \
  echo "Asia/Shanghai" > /etc/timezone; \
  apk del .tmp

COPY --from=builder /go/src/lotusmonitor/build/lotusmonitor /bin
COPY config.yml /etc/lotusmonitor/config.yml

WORKDIR /var/lotusmonitor

ENTRYPOINT ["/bin/lotusmonitor"]
